package com.itheima.handler;

import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author itheima
 * @since 2021-10-28
 */

@Component
@ControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public String doOtherException(Exception ex) {
        System.out.println(ex.getMessage());
        return ex.getMessage();
    }

}
